<template>
  <div class="course">
    <header-top />
    <div class="containerWid">
      <div
        class="courseClassify"
        @click="choiceClassify"
      >
        <span
          :class="{'on':current==index}"
          v-for="(item,index) in courseClassify"
          :key="index"
          :data-index="index"
        >{{item.name}}</span>
    </div>
    <div class="course-itemWrap">
      <div
        class="course-item"
        v-for="index in 10"
        :key="index"
      >
        <div class="picbox">
          <img src="@/assets/img/test/test.jpg">
          <div class="learnNum">
            <p>
              <i class="el-icon-user"></i>756人学习</p>
          </div>
        </div>
        <h3 class="name">Java架构师体系课：跟随千万级项目从0到100全过程高效成长</h3>
        <div class="coursePrice">
          <span class="price">￥56</span>
          <span class="buyBtn">立即购买</span>
        </div>
    </div>

  </div>
  <div class="tablePagination">
    <el-pagination
      background
      prev-text="上一页"
      next-text="下一页"
      layout="prev, pager, next"
      :total="100"
    >
      </el-pagination>
  </div>
  </div>
  <bottom-footer />
  </div>
</template>

<script>
import HeaderTop from '@/components/HeaderTop.vue'
import BottomFooter from '@/components/Footer.vue'
export default {
  components: {
    HeaderTop,
    BottomFooter
  },
  data() {
    return {
      current: 0,
      courseClassify: [
        { name: '全部' },
        { name: '计算机网络' },
        { name: 'HTML/CSS' },
        { name: 'JavaScript' },
        { name: 'Vue.js' },
        { name: 'React.JS' },
        { name: 'Angular' },
        { name: 'Node.js' },
        { name: 'jQuery' },
        { name: 'Sass/Less' },
        { name: 'WebApp' },
        { name: 'SpringBoot' },
        { name: 'Spring Cloud' },
        { name: 'SSM' },
        { name: '爬虫' },
        { name: 'Python' },
        { name: 'Django' },
        { name: 'Flask' },
        { name: 'Go' },
        { name: 'PHP' },
        { name: 'Swoole' },
        { name: 'C' },
        { name: 'C++' },
        { name: 'Android' },
        { name: 'iOS' },
        { name: '算法与数据结构' },
        { name: '大数据' },
        { name: 'Spark' },
        { name: '运维' },
        { name: '自动化运维' },
        { name: '中间件' },
        { name: 'Linux' },
        { name: '测试' },
        { name: 'MySQL' },
        { name: '产品交互' },
        { name: '设计基础' },
        { name: '动画效果' },
        { name: 'APPUI设计' },
        { name: '区块链' }
      ]
    }
  },
  mounted() {},
  methods: {
    choiceClassify(e) {
      const index = e.target.dataset.index
      console.log(index)
      this.current = index
    }
  }
}
</script>
<style lang="scss">
.courseClassify {
  padding: 24px 0 10px;
  border-bottom: 1px solid #e5e5e5;
  overflow: hidden;
  span {
    cursor: pointer;
    float: left;
    margin-right: 20px;
    padding: 0 12px;
    font-size: 14px;
    color: #4d555d;
    line-height: 32px;
    border-radius: 6px;
    margin-bottom: 12px;
    &.on {
      color: #c80;
      background: rgba(204, 136, 0, 0.1);
    }
    &:last-child {
      margin-right: 0;
    }
    &:not(.on):hover {
      background: #d9dde1;
    }
  }
}
.course-itemWrap {
  overflow: hidden;
  padding-top: 30px;
  .course-item {
    width: 270px;
    height: 254px;
    margin-right: 30px;
    margin-bottom: 36px;
    float: left;
    &:nth-child(4n) {
      margin-right: 0;
    }
    .picbox {
      width: 100%;
      height: 148px;
      border-radius: 8px;
      overflow: hidden;
      position: relative;
      img {
        display: block;
        width: 100%;
        height: 100%;
      }
      .learnNum {
        position: absolute;
        z-index: 0;
        background-image: linear-gradient(
          -180deg,
          rgba(7, 17, 27, 0) 0,
          rgba(7, 17, 27, 0.6) 97%
        );
        border-radius: 12px;
        left: 0;
        bottom: 0;
        right: 0;
        height: 74px;
        p {
          position: absolute;
          right: 0;
          left: 0;
          bottom: 10px;
          font-size: 14px;
          color: #fff;
          line-height: 18px;
          text-shadow: 0 2px 4px rgba(7, 17, 27, 0.5);
          @include textOverflow();
          padding: 0 20px;
          text-align: right;
          i {
            margin-right: 5px;
          }
        }
      }
    }
    .name {
      cursor: pointer;
      font-size: 16px;
      line-height: 24px;
      font-weight: 700;
      max-height: 48px;
      margin-top: 16px;
      transition: 0.3s all linear;
      word-break: break-all;
      word-wrap: break-word;
      overflow: hidden;
      text-overflow: -o-ellipsis-lastline;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      color: #2b333b;
      // @include textHover();
    }
    .coursePrice {
      margin-top: 10px;
      height: 32px;
      line-height: 32px;
      display: flex;
      justify-content: space-between;
      .price {
        font-size: 16px;
        color: #f20d0d;
        font-weight: 700;
      }
      .buyBtn {
        cursor: pointer;
        height: 30px;
        line-height: 30px;
        padding: 0 14px;
        border-radius: 20px;
        font-size: 14px;
        color: #333;
        border: 1px solid #333;
        transition: all 0.3s;
        &:hover {
          background-color: #333;
          color: #fff;
        }
      }
    }
  }
}
</style>
